package com.fang.distributed_locks.controller;

import com.fang.distributed_locks.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 测试redis的连接
 * @Author Bernie_fang
 * @Date 2024/2/19 22:03
 **/
@RequestMapping("/test")
@RestController
public class TestController {

    @Autowired
    private RedisUtils redisUtils;

    @GetMapping("/redis")
    public String testSet(String value) {
        redisUtils.set("ID",value, 10 * 60 * 1000L);
        return "success";
    }

    @GetMapping("/get/redis")
    public String testGet() {
        return (String) redisUtils.get("ID");
    }

}
